package com.demo.kafka.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MyKafkaController {

    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;

    private final static String TOPIC_NAME = "my-topic";

    @RequestMapping("/send")
    public String sendMsg() {
        kafkaTemplate.send(TOPIC_NAME,0,"KEY","MSG");
        return "SEND SUCCESS";
    }
}
